Otherwise, shooter keeps rolling, until roll same sum as original sum (shooter wins) or sum is 7 (casino wins).
What is the probability that shooter wins?
Flowchart for Craps
flowchart LR
D -->|   No   | F(   Roll <br> Again   )
subgraph Roll Again  
F(Roll Again  ) --> G[Roll 7?   ]
G -->|Yes   | H{   Lose   }
G -->|No   | I[Roll = <br> 1st roll?  ]
I -->|Yes   | J{   Win   }
I -->|No  | F
end
subgraph 1st Roll  
A(  Roll <br> Dice   ) --> B[  Roll <br>   7 or 11?   ]
B -->|   Yes   | C{   Win   }
B -->|   No   | D[  Roll 2 <br>   3 or 12?   ]
D -->|   Yes   | E{   Lose   }
end
In this example, could use probability theory to derive that the probability of winning is \(244/495 \approx 0.4929\).
Not feasible to derive solution in many examples.
Win on first roll
Let’s start with simpler problem:
what is the probability that shooter wins on first roll?
Can derive that probability equals \(2/9 \approx 0.2222\)
Now we use Monte Carlo simulation to approximate that probability.
Rolling a Die
First step: simulating one roll of a die:
R code: sample(1:6,1) which randomly drawing an element from {1,2,3,4,5,6}, each element equally likely, one time.
sample(1:6,1)
[1] 6
Rolling a Die
Rolls are random, each time can get different results:
sample(1:6,1)
[1] 3
sample(1:6,1)
[1] 1
sample(1:6,1)
[1] 5
sample(1:6,1)
[1] 1
Are results really random?
Computers are deterministic.
To create truly random numbers, can use a physical process, e.g., from nuclear decay or radioisotopes.
Not necessary for our purposes, and not what R is doing…
R is generating pseudo-random numbers
R generating pseudo-random numbers
R is generating pseudo-random numbers
starting point is a seed, in R determined by default by computer’s real time clock (time to the nanosecond that you run process), along with process ID number;
algorithm applied to seed to obtain pseudo-random numbers.
not actually random, as deterministic given seed, but close enough to random for our purposes.
Replication?
You may obtain different pseudo-random numbers each time you run your code, neither you nor others can replicate your results.
We say a sequence \(\bar{X}_n\) converges in probability to \(\mu\), written \(\bar{X}_n \stackrel{p}{\rightarrow} \mu\), if, for every \(\epsilon>0\), \[ \lim_{n \rightarrow \infty} \Pr[ | \bar{X}_n - \mu | \ge \epsilon] = 0.\]
Law of Large Numbers
Recall LLN for i.i.d. data.
Let \(X_1, . . . , X_n\) denote i.i.d. random variables, with \(\mathbb{E}[X_i]=\mu,\) finite. Then \(\bar{X}_n \stackrel{p}{\rightarrow} \mu\).
When \(X_i\) an indicator variable, \(\mathbb{E}[X_i]=p\) with \(0 \le p \le 1\), so \(\mathbb{E}[X_i]=\mu\) always exists, finite. Thus, by LLN, \(\bar{X}_n \stackrel{p}{\rightarrow} p\), i.e., \(\bar{X}_n\) approximates \(p\) arbitrarily well for \(n\) sufficiently large.
Original Problem
What is the probability that shooter wins pass line bet in craps?
First write function to simulate pass line bet.
Flowchart for Craps
flowchart LR
D -->|   No   | F(   Roll <br> Again   )
subgraph Roll Again  
F(Roll Again  ) --> G[Roll 7?   ]
G -->|Yes   | H{   Lose   }
G -->|No   | I[Roll = <br> 1st roll?  ]
I -->|Yes   | J{   Win   }
I -->|No  | F
end
subgraph 1st Roll  
A(  Roll <br> Dice   ) --> B[  Roll <br>   7 or 11?   ]
B -->|   Yes   | C{   Win   }
B -->|   No   | D[  Roll 2 <br>   3 or 12?   ]
D -->|   Yes   | E{   Lose   }
end
Function to simulate pass line bet
f.craps <-function(){# simulate first roll of dice sum0 <-sum(sample(1:6,2,replace=TRUE))# determine if win/lose on first roll# determine outcome if don't win/lose on first rollreturn(Win)}
Function to simulate pass line bet
f.craps <-function(){# simulate first roll of dice sum0 <-sum(sample(1:6,2,replace=TRUE))# determine if win/lose on first rollif (sum0 %in%c(7, 11)){ Win <-1 } elseif (sum0 %in%c(2, 3, 12)){ Win <-0 } else{# determine outcome if don't win/lose on first roll }return(Win)}
Function to simulate pass line bet
f.craps <-function(){# simulate first roll of dice sum0 <-sum(sample(1:6,2,replace=TRUE))# determine if win/lose on first rollif (sum0 %in%c(7, 11)){ Win <-1 } elseif (sum0 %in%c(2, 3, 12)){ Win <-0 } else{# determine outcome if don't win/lose on first rollwhile(TRUE){# keep rolling until someone wins } }return(Win)}
Function to simulate pass line bet
f.craps <-function(){# simulate first roll of dice sum0 <-sum(sample(1:6,2,replace=TRUE))# determine if win/lose on first rollif (sum0 %in%c(7, 11)){ Win <-1 } elseif (sum0 %in%c(2, 3, 12)){ Win <-0 } else{# determine outcome if don't win/lose on first rollwhile(TRUE){# keep rolling until someone wins sum1 <-sum(sample(1:6,2,replace=TRUE))if (sum1 == sum0){ Win <-1break } elseif (sum1 ==7){ Win <-0break } } }return(Win)}